class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        result = 0
        char_dict = dict()
        start_id = 0

        for i in range(len(s)):
            c = s[i]
            index = char_dict.get(c)
            if index is None or (index is not None and index < start_id):
                # 没有发现重复字符
                length = i + 1 - start_id
                result = max(result, length)
                char_dict[c] = i
                pass
            else:
                # 发现重复字符
                start_id = index + 1
                char_dict[c] = i
                pass

        return result

# abcabcbb 3
# bbbbb 1
# pwwkew 3
# abcae 4
# abcce 3
# wobgrovw 6
# abc 3
#   1
result2 = Solution().lengthOfLongestSubstring("wobgrovww1234567890")
print(result2)

t = "wobgrovww1234567890"

